const Koa = require('koa');
const app = new Koa();
const bodyParser = require('koa-bodyparser');
const Router = require('koa-router');
const router = new Router();
const static = require('koa-static');
const views = require('koa-views');

app.use(views(__dirname + '/views', {
    map: { html : 'ejs' }
}));

app.use(static(
    path.join(__dirname, '/static')
));

router.get('/', async (ctx, next) => {
    await ctx.render('index');
});

router.post('/', (ctx, next) => {
    let postData = ctx.request.body;
    ctx.body = postData;
});

app.use(bodyParser())
    .use(router.routes())
    .use(router.allowedMethods);

app.listen(3000);
